package viewmodel;


import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;

import com.uber.autodispose.FlowableSubscribeProxy;
import com.uber.autodispose.observers.AutoDisposingSubscriber;
import com.xgggh.redpack.domain.auth.Auth;
import com.xgggh.redpack.domain.redpack.Pack;

import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

import java.util.List;
import javax.inject.Inject;

import io.reactivex.Flowable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.subscribers.DisposableSubscriber;
import model.Rsp;
import model.Status;
import repository.RedPackRepository;

public class RedPackViewModel extends BaseViewModel<RedPackRepository> {
    RedPackRepository repository;
    @Inject
    public RedPackViewModel(RedPackRepository repository) {
        this.repository = repository;
    }

    public Flowable<Rsp<List<Pack>>> getRedPackList(int page ,int size,Pack pack) {
        if (pack==null){
            pack= new Pack();
        }
        Flowable<Rsp<List<Pack>>>  listRsp=repository.getRedPackList(page,size,pack);
        //data deal
        return listRsp;
    }

    public Flowable<Rsp<Pack>> createRedPack(Pack pack) {
        Flowable<Rsp<Pack>> data=repository.createRedPack(pack);
        return data;
        //return data;
        //data.map()
        //data.test()
       /* data.subscribe(new Consumer<Rsp<Pack>>() {
            @Override
            public void accept(Rsp<Pack> rsp) throws Exception {

            }
        });*/
    }

}
